﻿<div id="AjaxPaging">
    @using Webdiyer.WebControls.Mvc
    @model PagedList<NationalIT.Trip_Info>
    <script type="text/javascript">
        $(document).ready(function () {
            ajaxPagingByID("AjaxPaging");
        });
    </script>
    <table class="table">
        <tr>
            <th>
                <input type="checkbox" name="" value="" class="checkAll" />
            </th>
            <th>
                Invoice
            </th>
            <th>
                Order date
            </th>
            <th>
                Customer name
            </th>
            <th>
                Driver last name
            </th>
            <th>
                Pick up location
            </th>
            <th>
                Driver paid
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <input type="checkbox" name="checkOwner" value="@item.Trip_ID" class="checkitem"/>
                </td>
                <td>
                    @Html.ActionLink(item.Invoice + "", "NewOrEdit", new { id = item.Trip_ID })
                </td>
                <td>
                    @(item.Order_date.HasValue ? item.Order_date.Value.ToString("MM/dd/yyyy") : "")
                </td>
                <td>
                    @(item.Customer_Info != null ? item.Customer_Info.Customer_Name : "")
                </td>
                <td>
                    @if (item.Driver_Info != null)
                    {
                        @Html.ActionLink(item.Driver_Info.Last_name, "NewOrEdit", "DriverInfo", new { id = item.Driver }, null)
                    }
                </td>
                <td>
                    @item.Pick_up_location
                </td>
                <td>
                    @NationalIT.CommonFunction.getYesNO(item.Driver_paid)
                </td>
            </tr>
        }
    </table>
    <div class="row-fluid">
        <div class="span4">
            <div class="dataTables_info">
                @if (Model.TotalItemCount > 0)
                {
                    if (Model.TotalItemCount < Model.PageSize)
                    {
                    <span>1 </span>
                    <span>- </span>@Model.TotalItemCount
                    }
                    else
                    {
                    <span></span>@((Model.CurrentPageIndex - 1) * Model.PageSize + 1)
                    <span>- </span>@((Model.CurrentPageIndex != Model.TotalPageCount) ? (Model.CurrentPageIndex * Model.PageSize) : Math.Abs((Model.CurrentPageIndex) * Model.PageSize - (Model.PageSize * Model.TotalPageCount) - Model.TotalItemCount))
                    }
                    <span>of </span>@(Model.TotalItemCount)                            
                }
            </div>
        </div>
        <div class="span8">
            <div class="dataTables_paginate paging_bootstrap pagination phantrangmvcpager">
                @Html.AjaxPager(Model, new PagerOptions { ContainerTagName = "ul", PageIndexParameterName = "page", CurrentPagerItemWrapperFormatString = "<li class='active'>{0}</li>", CurrentPageNumberFormatString = "{0}", FirstPageText = "&laquo; ", LastPageText = " &raquo;", NextPageText = "Next →", PrevPageText = "← Prev", SeparatorHtml = "" }, new AjaxOptions { UpdateTargetId = "AjaxPaging" })
            </div>
        </div>
    </div>
</div>
